<?php
/**
 * common model file Created by PhpStorm.
 * User: wumengmeng
 * Date: 2020/05/11
 * Time: 16:24
 */

namespace HiCommon\Model;

class Handbook extends Base
{
    protected $table = 'handbook';

    protected $guarded = [];

    //一对多
    public function get_handbook_upkeep_type()
    {
        return $this->hasMany(HandbookUpkeepType::class, 'handbook_id', 'id')
            ->with(['get_upkeep_type']);
    }

    //连带删除
    protected static function boot()
    {
        parent::boot();

        static::deleting(function($obj) {
            $obj->get_handbook_upkeep_type()->forceDelete();
        });
    }
}